/**
 * Copyright 2008-2009 HAN.BIFANG
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 */
package han.bifang.gwt.client.service.content;

import han.bifang.gwt.client.common.Content;
import han.bifang.gwt.client.common.EntityConstants;
import han.bifang.gwt.client.common.GwtContext;
import han.bifang.gwt.client.common.entity.Version;
import han.bifang.gwt.client.communicate.BifangGWTServiceAsync;
import han.bifang.gwt.client.service.ServiceMessages;

import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
import com.google.gwt.user.client.ui.HTMLTable.ColumnFormatter;

/**
 * 
 * @Author Kent
 */
public class VersionBasicContent extends Content {

	private BifangGWTServiceAsync service = null;

	private GwtContext context = null;

	private ServiceMessages cons;

	private VerticalPanel panel = null;

	
	public VersionBasicContent(ServiceMessages cons,
			BifangGWTServiceAsync service, GwtContext context, Version v) {
		this.cons = cons;
		this.service = service;
		this.context = context;
		panel = new VerticalPanel();
		panel.setSpacing(5);
		panel.setWidth("100%");

		HTML h = new HTML(cons.versionBasicInfo());
		panel.add(h);

		Grid table = new Grid(4, 2);
		table.setWidth("100%");
		table.setCellPadding(1);
		table.setCellSpacing(1);
		table.setBorderWidth(1);

		ColumnFormatter cf = table.getColumnFormatter();
		cf.setWidth(0, "15%");
		cf.setWidth(1, "55%");

		CellFormatter ff = table.getCellFormatter();
		ff.setStyleName(0, 0, "tablecol");
		ff.setStyleName(1, 0, "tablecol");
		ff.setStyleName(2, 0, "tablecol");
		ff.setStyleName(3, 0, "tablecol");

		table.setHTML(0, 0, cons.version());
		table.setHTML(1, 0, cons.createTime());
		table.setHTML(2, 0, cons.status());
		table.setHTML(3, 0, cons.desc());


		table.setHTML(0, 1, v.getVersion());
		table.setHTML(1, 1, v.getPublishTime());
		table.setHTML(2, 1, v.getStatus().equals(EntityConstants.VERSION_STATUS_PUBLISHED) ? cons.published() : cons.unpublished());
		table.setHTML(3, 1, v.getDescription());
		panel.add(table);
		initWidget(panel);

	}

	

}
